package com.heyou.ticket.controller;

import com.heyou.ticket.assistant.HeyouAgent;
import com.heyou.ticket.entity.TicketBookDetail;
import com.heyou.ticket.tools.TicketBookDetailTools;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Flux;

import java.util.List;

/**
 * <p>
 * 机票预定信息表 前端控制器
 * </p>
 *
 * @author liangsw
 * @since 2025-05-12
 */
@CrossOrigin
@Tag(name = "机票预定信息")
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/ticket")
public class TicketBookDetailController {

    private final TicketBookDetailTools ticketBookDetailTools;
    private final HeyouAgent heyouAgent;


    // 查询所有的机票预定信息
    @CrossOrigin
    @Operation(summary = "查询所有的机票预定信息")
    @GetMapping("/book")
    public List<TicketBookDetail> getAllTicketBook() {
        return ticketBookDetailTools.getAllTicketBookDetails();
    }

    @CrossOrigin
    @Operation(summary = "流式聊天")
    @GetMapping("/stream/chat")
    public Flux<String> streamChat(@RequestParam(defaultValue = "查询所有的机票预定信息") String message) {
        return this.heyouAgent.streamChat(message);
    }

    @CrossOrigin
    @Operation(summary = "常规聊天")
    @GetMapping("/chat")
    public String chat(String message) {
        return this.heyouAgent.chat(message);
    }
}
